package com.yunfeisoft.business.service.impl;

import com.applet.base.BaseServiceImpl;
import com.applet.sql.separation.DataSourceChange;
import com.applet.utils.Page;
import com.yunfeisoft.business.dao.inter.PmsProductCategoryDao;
import com.yunfeisoft.business.model.PmsProductCategory;
import com.yunfeisoft.business.service.inter.PmsProductCategoryService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * ClassName: PmsProductCategoryServiceImpl
 * Description: 商品分类表service实现
 * Author: Jackie liu
 * Date: 2020-06-02
 */
@Service("pmsProductCategoryService")
public class PmsProductCategoryServiceImpl extends BaseServiceImpl<PmsProductCategory, String, PmsProductCategoryDao> implements PmsProductCategoryService {

    @Override
    @DataSourceChange(slave = true)
    public Page<PmsProductCategory> queryPage(Map<String, Object> params) {
        return getDao().queryPage(params);
    }

    @Override
    public List<PmsProductCategory> queryList(Map<String, Object> params) {
        return getDao().queryList(params);
    }

    @Override
    public int modifyShowStatus(String id, int showStatus) {
        if (StringUtils.isBlank(id)) {
            return 0;
        }

        PmsProductCategory productCategory = new PmsProductCategory();
        productCategory.setId(id);
        productCategory.setShowStatus(showStatus);
        return getDao().update(productCategory);
    }

    @Override
    public int modifyNavStatus(String id, int navStatus) {
        if (StringUtils.isBlank(id)) {
            return 0;
        }

        PmsProductCategory productCategory = new PmsProductCategory();
        productCategory.setId(id);
        productCategory.setNavStatus(navStatus);
        return getDao().update(productCategory);
    }
}